package com.ziwei.material.domain.vo;

import com.ziwei.material.constant.CommonConstants;
import lombok.Data;

/**
 * @author: jl_zhang
 * @since: 2024/11/14 14:40
 **/
@Data
public class ResultVo<T> {
    private Integer code;
    private String msg;
    private T data;

    public static<T> ResultVo<T> fail(String msg){
        ResultVo<T> resultVo = new ResultVo<>();
        resultVo.setCode(Integer.valueOf(CommonConstants.FAIL));
        resultVo.setMsg(msg);
        return resultVo;
    }

    public static<T> ResultVo<T> success(String msg, T data){
        ResultVo<T> resultVo = new ResultVo<>();
        resultVo.setCode(Integer.valueOf(CommonConstants.SUCCESS));
        resultVo.setMsg(msg);
        resultVo.setData(data);
        return resultVo;
    }
}
